import requests
# def get_html(url):
#     head = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"}
#     try:
#         r = requests.get(url=url,headers=head)
#         r.encoding = r.apparent_encoding
#         r.raise_for_status()
#         return r.text
#
#     except Exception as err:
#         print(err)
#
#
# if __name__ == '__main__':
#     url_1 = 'https://www.tencent.com/zh-cn/'
#     print(get_html(url_1))

import requests
try:
    url = 'http://www.bspider.top/static/yh31/images/202103302056530751.gif'
    r = requests.get(url)
    r .raise_for_status()
    r.encoding = r.apparent_encoding
    with open('1,gif','wb+')as f:
        f.write(r.content)
except Exception as err:
    print(err)

import requests
try:
    url_list = ["http://www.bspider.top/static/yh31/images/202103302056530751.gif",
                "http://www.bspider.top/static/yh31/images/202103182029425871.jpg"]
    for url in url_list:
        r=requests.get(url,timeout=3)
        dir="d:\\"
        file_name=url.split("/")[-1:][0]
        file_name=dir+file_name
        with open(file_name,"wb+")as f:
            f.write(r.content)
except Exception as err:
    print(err)


